<script setup>
import { ref } from "vue"

let tabbar_data_list = ref([
    {
        title: "书城", icon: "shop-o", badge: "1", link: "/index",
        tabbar_color: {
            color: "#ee0a24"
        }
    },
    {
        title: "社区", icon: "smile-comment-o", badge: "10", link: "/community",
        tabbar_color: {
            color: "#746c6c"
        }
    },
    {
        title: "福利", icon: "gift-o", badge: "5", link: "/welfare",
        tabbar_color: {
            color: "#746c6c"
        }
    },
    {
        title: "我的", icon: "manager-o", badge: "3", link: "/my",
        tabbar_color: {
            color: "#746c6c"
        }
    },

])
let is_selected = false
let tabbar_color = ref(
    {
        color: "#746c6c"
    }
)

function selected(index){

        this.tabbar_data_list[index].tabbar_color.color = "#ee0a24"
        if(index == 0){
            this.tabbar_data_list[index+1].tabbar_color.color = "#746c6c"
            this.tabbar_data_list[index+2].tabbar_color.color = "#746c6c"
            this.tabbar_data_list[index+3].tabbar_color.color = "#746c6c"
        }else if (index == 1){
            this.tabbar_data_list[index-1].tabbar_color.color = "#746c6c"
            this.tabbar_data_list[index+1].tabbar_color.color = "#746c6c"
            this.tabbar_data_list[index+2].tabbar_color.color = "#746c6c"
        }else if (index == 2){
            this.tabbar_data_list[index-2].tabbar_color.color = "#746c6c"
            this.tabbar_data_list[index-1].tabbar_color.color = "#746c6c"
            this.tabbar_data_list[index+1].tabbar_color.color = "#746c6c"
        }else if (index == 3){
            this.tabbar_data_list[index-3].tabbar_color.color = "#746c6c"
            this.tabbar_data_list[index-2].tabbar_color.color = "#746c6c"
            this.tabbar_data_list[index-1].tabbar_color.color = "#746c6c"
        }
       
}


</script>

<template>
    <div class="tabbar">
        <!-- 底部导航栏 -->
        <div class="bottom-tabbar">
            <div class="tabbar-list">
                <ul>
                    <li v-for="(value, index) in tabbar_data_list" :key="i">
                        <router-link :to="value.link" >
                            <div @click="selected(index)">
                                <van-icon :name="value.icon" size="30" :badge="value.badge" :color="value.tabbar_color.color" />
                                <p :style=value.tabbar_color>{{ value.title }}</p>
                            </div>
                            
                        </router-link>
                    </li>
                </ul>
            </div>
        </div>


    </div>
    <!-- :color="tabbar_color.color"
    <!-- :style=tabbar_color -->
</template>

<style scoped>
.tabbar {
    height: 60px;

}

.bottom-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    height: 60px;
    width: 100%;
    border-top: 1px solid #746c6c;
    border-top-right-radius: 5px;
    border-top-left-radius: 5px;
    /* background:linear-gradient(45deg,#fc6076 0%, #ff9a44 100%); */
}

.tabbar-list {
    max-width: 1080px;
    height: 60px;
    margin: auto;
}

.tabbar-list ul {
    height: 100%;
    display: flex;
    justify-content: space-around;
    align-content: center;
    align-items: center;
    text-align: center;
}

.tabbar-list ul li {
    height: 100%;
    width: 15%;
    display: flex;
    flex-wrap: wrap;
    /* font-size:0; */
    
}

.tabbar-list ul li img {
    width: 30px;
    height: 30px;
}

.tabbar-list ul li p {
    position: fixed;
    bottom: -12px;
    color: #746c6c;
}
</style>